import http from '../http.js'

// 分页查询采购订单（后端：POST /procurement/purchase/order/page，pageNum/pageSize 作为查询参数）
export function listPurchaseOrder(query) {
  const { pageNum = 1, pageSize = 10, ...dto } = query || {}
  // 同时兼容后端对 current/size 的参数命名
  const params = { pageNum, pageSize, current: pageNum, size: pageSize }
  return http.post('/procurement/purchase/order/page', dto, { params })
}

// 获取采购订单详情
export function getPurchaseOrder(id) {
  return http.post('/procurement/purchase/order/getById', { id })
}

// 新增采购订单
export function addPurchaseOrder(data) {
  return http.post('/procurement/purchase/order', data)
}

// 更新采购订单（占位，若后端未提供可忽略调用）
export function updatePurchaseOrder(data) {
  return http.put('/procurement/purchase/order', data)
}

// 删除采购订单（占位，若后端未提供可忽略调用）
export function delPurchaseOrder(id) {
  return http.delete(`/procurement/purchase/order/${id}`)
}

// 生成采购订单号
export function generateOrderNo() {
  return http.post('/procurement/purchase/order/generateOrderNo')
}

// 导出采购订单（占位，若后端未提供可忽略调用）
export function exportPurchaseOrder(params) {
  return http.post('/procurement/purchase/order/export', params, { responseType: 'blob' })
}
